
/**   
 * @Title: NonSwipeableViewPager.java 
 * @Package: com.rename.view 
 * @Description: Administrator版权所有
 * @author Administrator  
 * @date 2015-2-11 下午2:06:59 
 * @version  
 */


package com.rename.icode.view;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/** 
 * @Description 实现了...功能
 * @author Administrator
 * @date 2015-2-11 下午2:06:59 
 * @version V1.0
 */

public class NonSwipeableViewPager extends ViewPager {

	
	private boolean swipe = true;

    public boolean isSwipe() {
        return swipe;
    }

    public void setSwipe(boolean swipe) {
        this.swipe = swipe;
    }

    public NonSwipeableViewPager(Context context) {
        super(context);
    }    

    public NonSwipeableViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {

        if (swipe) {
            return super.onInterceptTouchEvent(arg0);
        }

        // Never allow swiping to switch between pages
        return false;
    }

    
    @Override
    public boolean onTouchEvent(MotionEvent ev){
    	 if (swipe) {
             return super.onTouchEvent(ev);
         }

         // Never allow swiping to switch between pages
         return false;
    }

}
